const fs = require('fs')

//同步打开文件
let fd = fs.openSync('test1.txt', 'w')
console.log(fd)

// 写入文件
let str = "Hello, world!"
fs.writeFileSync(fd, str);

//关闭文件
fs.closeSync(fd)